<!DOCTYPE html>
<html class="ui-page-login">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/style.css" rel="stylesheet" />
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">投料复核</h1>
		</header>
		<div class="mui-content">
			<div id='login-form' class="mui-input-group">
				<div class="mui-input-row row">
					<input id='BarCode' type="text" class="mui-input-clear BarCode" autofocus="true" placeholder="请扫描工单上二维码">
				</div>
			</div>
			<div class="mui-input-group item">
				<div class="mui-input-row">
					<label class="title">计划单号:</label>
					<label id="lblPlanNumber" class="intocontent"></label>
					<input type="hidden" id="txtPlanSnNum" name="txtPlanSnNum" value="">
				</div>
			</div>
			<div class="mui-input-group item">
				<div class="mui-input-row">
					<label class="title">工单号:</label>
					<label id="lblOrderNum" class="intocontent"></label>
				</div>
			</div>
			<div class="mui-input-group item" style="display: none;">
				<div class="mui-input-row">
					<label class="title">客户名称:</label>
					<label id="lblCusName" class="intocontent"></label>
				</div>
			</div>
			<div class="mui-input-group item">
				<div class="mui-input-row">
					<label class="title">产品名称:</label>
					<label id="lblProductName" class="intocontent" style="font-size: 12px;"></label>
				</div>
			</div>
			<div class="mui-input-group item">
				<div class="mui-input-row">
					<label class="title">产品代号:</label>
					<label id="lblProductBarCode" class="intocontent"></label>
				</div>
			</div>
			<div class="mui-input-group item">
				<div class="mui-input-row">
					<label class="title">配方代号:</label>
					<label id="lblBomNumber" class="intocontent"></label>
				</div>
			</div>
			<div class="mui-input-group item">
				<div class="mui-input-row">
					<label class="title">预计产量:</label>
					<label id="lblQty" class="intocontent"></label>
				</div>
			</div>
			<div class="mui-content-padded" style="text-align: center; margin-top: 12px;">
				<button id='btnBack' type="button" class="mui-btn mui-btn-primary mui-btn-outlined">返回主页</button>
				<!-- <button id='btnDetail' type="button" class="mui-btn mui-btn-success mui-btn-outlined">查看详细</button> -->
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
		<script type="text/javascript" src="../js/moment.min.js"></script>
		<script type="text/javascript" src="../js/git.mes.common.js"></script>
		<script type="text/javascript" src="../js/git.mes.key.js"></script>
		<script type="text/javascript">
			mui.plusReady(function(){

				plus.webview.currentWebview().addEventListener("show",function(e){
	                setTimeout(function() {
                        openSoftKeyboard();
                        document.getElementById("BarCode").focus();
                        closeKeyBoard();
                    	plus.key.hideSoftKeybord();
                    }, 300);
	            });

				var PlanEntity=undefined;
				/**
				 * 扫描生产计划任务单二维码
				 * [GetPlan description]
				 * @param {[type]} BarCode [description]
				 */
				var GetPlan=function(BarCode){
					var param={};
					param["PlanNumber"]=BarCode;
					git.gitAjax({
						url:PlanApiName.PlanApiName_GetPlanByNumber,
						data:param,
						type:"get",
						success:function(result){
							if(result.Code==1 && result.Result!=undefined){
								PlanEntity=result.Result;
								$("#lblPlanNumber").text(PlanEntity.PlanNumber);
								$("#lblOrderNum").text(PlanEntity.OrderNum);
								$("#txtPlanSnNum").val(PlanEntity.SnNum);
								$("#lblCusName").text(PlanEntity.CusName);
								$("#lblProductName").text(PlanEntity.ProductName);
								$("#lblProductBarCode").text(PlanEntity.BarCode);
								$("#lblBomNumber").text(PlanEntity.BomNumber);
								$("#lblQty").text(PlanEntity.PlanQty+"kg");
								GoDevice();
							}else{
								git.PlayerError();
								$("#lblPlanNumber").text("");
								$("#lblOrderNum").text("");
								$("#txtPlanSnNum").val("");
								$("#lblCusName").text("");
								$("#lblProductName").text("");
								$("#lblProductBarCode").text("");
								$("#lblBomNumber").text("");
								$("#lblQty").text("");
							}
						}
					});
				}

				/**
				 * 进入扫描设备页面
				 * [GoDevice description]
				 */
				function GoDevice(){
					setTimeout(function(){
						mui.openWindow({
							id:"ScanDevice.html",
							url:"ScanDevice.html",
							createNew:false,
							show:{
								autoShow:true,
							},
							extras:{Result:PlanEntity}
						});
					},200);
				}

				document.getElementById("BarCode").addEventListener("keypress", function(event) {
			        if (event.keyCode == "13"){
			        	var BarCode=$("#BarCode").val();
			            if(!git.IsEmpty(BarCode)){
			            	GetPlan(BarCode);
			            	$("#BarCode").val("");
			            }else{
			            	git.PlayerError();
			            }
			        }
			    });
			    
				/**
				 * 退回到主页
				 * [description]
				 * @param  {[type]} ){					mui.openWindow({						id:"../main.html",						url:"../main.html",						createNew:false,						show:{							autoShow:true,						}					});				} [description]
				 * @return {[type]}                                                                                                                                                           [description]
				 */
				document.getElementById("btnBack").addEventListener("tap",function(){
					mui.openWindow({
						id:"../main.html",
						url:"../main.html",
						createNew:false,
						show:{
							autoShow:true,
						}
					});
				});

				/**
				 * 查看投料明细
				 * [description]
				 * @param  {[type]} ){					mui.openWindow({						id:"../main.html",						url:"../main.html",						createNew:false,						show:{							autoShow:true,						}					});				} [description]
				 * @return {[type]}                                                                                                                                                           [description]
				 */
				// document.getElementById("btnDetail").addEventListener("tap",function(){
				// 	mui.openWindow({
				// 		id:"Detail.html",
				// 		url:"Detail.html",
				// 		createNew:false,
				// 		show:{
				// 			autoShow:true,
				// 		},
				// 		extras:{Result:PlanEntity.PlanNumber}
				// 	});
				// });
			});
		</script>
	</body>

</html>